#pragma once

#include <string>
#include <map>
#include "CLComLibrarys_global.h"
#include "CLComString.h"
//CLCOMLIBRARYS_EXPORT

using namespace std;

enum ECLCOMVALUE_TYPE
{
    ECLCOMVALUE_TYPE_NO = 0,
    ECLCOMVALUE_TYPE_INT,
    ECLCOMVALUE_TYPE_DOUBLE,
    ECLCOMVALUE_TYPE_STRING,
    ECLCOMVALUE_TYPE_POBJ,
};

class CLCOMLIBRARYS_EXPORT CLComValue
{
public:
    CLComValue();
    CLComValue(const char* key);
    CLComValue(const CLComValue& other);
    ~CLComValue();
    void DeepCopy(const CLComValue& other);
public:
    void SetIntValue(long long llValue);
	void SetDoubleValue(double dValue);
	void SetStringValue(const char* strValue);
    void SetObjValue(void* pValue, long long nLen);
    void SetObjValueDeep(void* pValue, long long nLen);
	void SetKey(const char* key);
public:
    ECLCOMVALUE_TYPE GetDType()const;
    void SetDType(ECLCOMVALUE_TYPE dtype);
public:
    CLComValue& operator=(const CLComValue& other);

public:
	const char* GetKey()const ;
    long long	GetIntValue()const;
	double GetDoubleValue()const;
	const char* GetStringValue()const;
	void* GetPObject()const;
    long long GetPObjectLen()const;

public:
	static bool FindAttributeDouble(
        map<string, CLComValue>& checkAttribute,
		string key,
		double& dValue);

	static bool FindAttributeString(
        map<string, CLComValue>& checkAttribute,
		string key,
		string& strValue);

	static bool FindAttributeBigInt(
        map<string, CLComValue>& checkAttribute,
		string key,
        long long& nValue);

	static bool FindAttributeInt(
        map<string, CLComValue>& checkAttribute,
		string key,
		int& nValue);

	static bool FindAttributeObject(
        map<string, CLComValue>& checkAttribute,
		string key,
		unsigned char*& pValue);

private:
	void Init();
    void CopyValue(const CLComValue& other, bool bobjDeep);
private:
    char*		m_pObj;
    long long	m_llObjLen;

    CLComString m_valuestr;
    CLComString m_keystr;

    ECLCOMVALUE_TYPE	m_eDType;
};


